home *** CD-ROM | disk | FTP | other *** search
Text File | 1998-10-13 | 5.7 KB | 170 lines | [TEXT/CWIE] |
- //=====================================================================================
- // File: FinderPopAPI.h
- //
- // Contains: FinderPop Application Programming Interface
- //
- // Written by: turly o’connor, cork, ireland turly@geocities.com
- //
- // Copyright: 1997, 1998 by Turlough O'Connor, all rights reserved.
- //
- // Change History (most recent first):
- // <02> 18-Sep-98 tur Add Beta version of FinderPoplets. Haven't tried
- // it myself yet!
- // <01> 31-Aug-98 tur Make Beta Version publicly available.
- //
- //=====================================================================================
-
- #ifndef __FinderPop__
- #define __FinderPop__
-
- #include <Events.h>
- #include <Processes.h>
- #include <AppleEvents.h>
-
- #if PRAGMA_ALIGN_SUPPORTED
- #pragma options align=mac68k
- #endif
-
- enum {
- kFinderPopAPIGestaltSignature = 'FpoP',
- kFinderPopletFileType = 'Fplt',
- kFinderPopletRsrcType = 'Fplt',
- kFinderPopletRsrcID = 128,
-
- uppFinderPopAPIProcInfo = kPascalStackBased
- | RESULT_SIZE(SIZE_CODE(sizeof(SInt32)))
- | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(UInt32)))
- | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(SInt32)))
-
- };
-
- //
- // for FinderPoplets™... 68K SysHeap 'Fplt' ID=128 resource, just jumped to
- // with TFinderPopletInfo parameter. Filetype should be kFinderPopletFileType.
- //
- // Handy for things like "Show Finder and Hide Others", which so many people have
- // requested it’s driving me nuts!
- //
- // 'Fplt' routine can return one of:
-
- enum {
- kFinderPopletDetachAndStayResident = 1, // SysHeap 'Fplt' rsrc is detached and the 'Fplt' file is closed;
- // bu detached Fplt code rsrc continues to be called
-
- kFinderPopletTerminate, // if 'Fplt' file was open, it's closed (and 'Fplt' rsrc
- // disappears, never to be called again)
- // if 'Fplt' file was closed, 'Fplt' handle is DisposeHandle-d.
-
- kFinderPopletContinue // Continue calling Fplt as normal...
- };
-
- enum { kCurrentFinderPopletVersion = 1 };
-
- typedef struct {
- UInt32 fpltVersion; // version of FinderPoplet record
- UInt32 fpltRefCon; // all yours - whatever you returned last time
- EventRecord *fpltEvent; // as passed to GNEFilterProc (*BUT* can be NULL!)
- OSType fpltCurrentProcessSig; // for your convenience, sah!
- ProcessSerialNumber fpltCurrentProcessPSN; // ditto
- const AEDesc *flptSelection; // "inSelection" parameter to _ContextualMenuSelect (or NULL)
- UInt32 fpltPrivate[2]; // private parts.
- UInt32 fpltReserved[4]; // currently zeroed
- } TFinderPopletInfo;
-
- typedef pascal UInt32 (*TFinderPopletProc)(TFinderPopletInfo *info);
-
- enum { // FinderPopAPIProc selectors
- // 0 .. 8 private
-
- kFPPGetFinderPopActive = 9, // <- 0 (off) .. 1 (on)
- kFPPGetAutoPopupDelay, // <- 0 (off) .. 120 ticks
- kFPPSetAutoPopupDelay, // -> 0 (off) .. 120 ticks
- kFPPLaunchFinderPopletFile, // -> FSSpec of some file containing 'Fplt'=128
- kFPPLaunchFinderPopletHandle, // -> Handle to TFinderPopletProc (in sysHeap, preferably :-)
- kFPPGetVersion, // return FinderPop version (from 'vers')
- // kFPPSetOKToAutoPopup, // -> nonzero --> OK to autopopup, regardless of QD activity
- kFPPIllegalSelector = -999
- };
-
- #ifdef __cplusplus
- extern "C" {
- #endif
-
- typedef struct OpaqueFinderPopCookie *TFinderPopCookie;
-
- extern TFinderPopCookie OpenFinderPopConnection(void);
- extern TFinderPopCookie CloseFinderPopConnection(TFinderPopCookie theConnection);
-
- extern SInt32 FinderPopAPIProc(TFinderPopCookie cookie, UInt32 selector, SInt32 param);
-
- #ifdef __cplusplus
- } /* extern "C" */
- #endif
-
- //
- // Accessors.
- //
-
- #ifdef __cplusplus
-
- inline Boolean IsFinderPopActive(TFinderPopCookie cookie) {
- return FinderPopAPIProc(cookie, kFPPGetFinderPopActive, 0);
- }
- inline SInt32 GetFinderPopAutoPopupDelay(TFinderPopCookie cookie) {
- return FinderPopAPIProc(cookie, kFPPGetAutoPopupDelay, 0);
- }
- inline OSErr SetFinderPopAutoPopupDelay(TFinderPopCookie cookie, unsigned int value0_127) {
- return FinderPopAPIProc(cookie, kFPPSetAutoPopupDelay, value0_127);
- }
- inline OSErr LaunchFinderPopletFile(TFinderPopCookie cookie, const FSSpec *fsspecptr) {
- return FinderPopAPIProc(cookie, kFPPLaunchFinderPopletFile, (SInt32)fsspecptr);
- }
- inline OSErr LaunchFinderPopletHandle(TFinderPopCookie cookie, Handle fpltHandle) {
- return FinderPopAPIProc(cookie, kFPPLaunchFinderPopletHandle, (SInt32)fpltHandle);
- }
-
- #else /* horrible C preprocessor macros */
-
- #define /*Bool*/ IsFinderPopActive(cookie) \
- FinderPopAPIProc(cookie, kFPPGetFinderPopActive, 0)
- #define /*int*/ GetFinderPopAutoPopupDelay(cookie) \
- FinderPopAPIProc(cookie, kFPPGetAutoPopupDelay, 0)
- #define /*OSErr*/ SetFinderPopAutoPopupDelay(cookie, value0_127) \
- FinderPopAPIProc(cookie, kFPPSetAutoPopupDelay, value0_127)
- #define /*OSErr*/ LaunchFinderPopletFile(cookie, fsspecptr) \
- FinderPopAPIProc(cookie, kFPPLaunchFinderPopletFile, (SInt32)fsspecptr)
- #define /*OSErr*/ LaunchFinderPopletHandle(cookie, fpltHandle) \
- FinderPopAPIProc(cookie, kFPPLaunchFinderPopletHandle, (SInt32)fpltHandle)
-
- #endif /* __cplusplus */
-
- /*
- Usage example:
-
- TFinderPopCookie finderPopCookie = OpenFinderPopConnection();
-
- if (finderPopCookie != 0) // FP is installed
- {
- if (IsFinderPopActive(finderPopCookie))
- printf("FinderPop is installed and active\n");
- else
- printf("FinderPop in installed but turned off\n");
-
- SInt32 fpAutoPopupDelay = GetFinderPopAutoPopupDelay(finderPopCookie);
- (void)SetFinderPopAutoPopupDelay(finderPopCookie, 0);
-
- ...do something...
-
- (void)SetFinderPopAutoPopupDelay(finderPopCookie, fpAutoPopupDelay);
-
- finderPopCookie = CloseFinderPopConnection(finderPopCookie);
- }
-
- */
-
- #if PRAGMA_ALIGN_SUPPORTED
- #pragma options align=reset
- #endif
-
- #endif /* __FinderPop__ */
-